package com.ahcfl.dao;

import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param;

public class StudentSqlProvider {

    public String findAllStudentsCount(@Param("name") String name){

        StringBuffer sb  = new StringBuffer("select count(*) from student ");
        if(StringUtils.isNotEmpty(name)){
            sb.append(" where stu_name like concat('%',#{name},'%') ");
        }


        return sb.toString();
    }

    public String findAllStudents(@Param("start") int start,
                                         @Param("pageSize") int pageSize,
                                         @Param("name") String name){
        StringBuffer sb  = new StringBuffer("select * from student ");
        if(StringUtils.isNotEmpty(name)){
            sb.append(" where stu_name like concat('%',#{name},'%') ");
        }
        sb.append("limit #{start},#{pageSize}");

        return sb.toString();
    }
}
